package top.toptimus.dto.dbSync.syncDatas;

import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.Map;

@AllArgsConstructor
@NoArgsConstructor
@Data
/**
 * 供货商DTO
 */

public class VenderMeterialDTO {
    private String vender_id;   //机构ID
    private String material_id; //原辅料ID
    private String brand_id;   //品牌ID

    /**
     * 将数据放到 map集合中
     *
     * @param map
     */
    public VenderMeterialDTO(Map<String, Object> map) {
        this.vender_id = map.containsKey("vender_id")?map.get("vender_id").toString():"";
        this.material_id = map.containsKey("material_id")?map.get("material_id").toString():"";
        this.brand_id = map.containsKey("brand_id")?map.get("brand_id").toString():"";
    }

    /**
     * 将数据放到 i_vender_meterial_r表中
     *
     * @return
     */
    public String VenderMeterialDTOSql() {
        String sql = "INSERT INTO `fragsmart-erp`.`i_vender_meterial_r` ( `vender_id`, `material_id`, `brand_id` )\n" +
                "VALUES\n" +
                "	( " + this.vender_id + ", " + this.material_id + ", " + this.brand_id + " );";

        return sql;
    }
}
